package com.hycat.mail.common.exception;

import com.hycat.mail.common.model.ExceptionEnum;
import lombok.Data;
import lombok.Getter;

import java.text.MessageFormat;

/**
 * @author : lzhycat
 * @date : 2022-07-19 15:56
 */
@Getter
public class MailException extends RuntimeException{
    private String code;
    private Object[] args;

    public MailException(String code, String msg) {
        super(msg);
        this.code = code;
    }

    public MailException(ExceptionEnum exceptionEnum) {
        super(exceptionEnum.getMsg());
        this.code = exceptionEnum.getCode();
    }

    public MailException(ExceptionEnum exceptionEnum, Object... args) {
        super(MessageFormat.format(exceptionEnum.getMsg(), args));
        this.code = exceptionEnum.getCode();
        this.args = args;
    }

}
